import { defineConfig } from "vite";

export default defineConfig(config => {
  if (config.command = 'build') {
    return {
      base: "./",
      worker: {
        rollupOptions: {
          output: {
            entryFileNames: "worker/[name].js",
            chunkFileNames: "worker/[name].js",
            assetFileNames: "worker/[name].[ext]",
          }
        }
      },
      build: {
        assetsDir: "",
        minify: false,
        lib: {
          entry: "src/lib/index.js",
          name: "lesterchn",
          formats: ["cjs"]
        },
        sourcemap: false,
        rollupOptions: {
          output: {
            entryFileNames: "index.js",
            chunkFileNames: "lib/[name].js",
            assetFileNames: "lib/[name].[ext]",
          },
        }
      }
    }
  }

  return {
    optimizeDeps: {
      include: [
        "monaco-editor/esm/vs/editor/edcore.main",
        "monaco-editor/esm/vs/editor/editor.worker",
        "monaco-editor/esm/vs/language/json/json.worker"
      ]
    }
  }

})